<?php
	
		$cache=new Cache;
		$data=$cache->load('home_data','home');
		
		if(!$data){
			
				$sql ="select id from truyen  where pick = 1 and duyet=1 order by time_update desc ";
				$sql2="select id from truyen where pick = 1 ";
			
				$pager = new Pagination($sql,DECU_ITEMS,4,'',0,"truyen_1");
				$pager->setDebug(false);
				$data['decu'] = $pager->paginate($cache,$sql2);
				$total= $pager->total_rows;

				$data['decu_pages'] = ceil($total / DECU_ITEMS);
				if($data['decu_pages'] > DECU_MAX_PAGE){
					$data['decu_pages'] = DECU_MAX_PAGE;
				}
		
		
	
		
		$sql ="select id from truyen  where duyet=1 order by time_update desc ";
		$sql2="select id from truyen where duyet=1 ";
		$pager = new Pagination($sql,8,4,'',0,"truyen_1");
		$pager->setDebug(false);
		$data['truyenmoi'] = $pager->paginate($cache,$sql2);
		
		//-------------------------Get video
		$db=new db;
		$db->connect();
		$db->query("select id from index_post where is_video=1 order by id desc limit 0,9");
		$dt=$db->fetchAll();
		
		foreach($dt as $row){
			$data['video'][]=get_post($row['id']);
		}
		//-------------------------get blog
		$db->close(); 
		// Close db connection -------
		
		
		
		// GET CATEGORY IN HEAD -------
					 $db=new db;
					  $db->connect();
					  $db->query('select * from category where video_type=1 and p_id=0 order by thutu asc');
					  $cat['video']= $dt=$db->fetchAll();
					  $db->query('select * from category where text_type=1 and p_id=0 order by thutu asc');
					  $cat['blog']= $dt=$db->fetchAll();
					 
					  $db->close();
								  
			
					  $data['category']=$cat;
				//End of get category in head --
		// GET BLOG ITEM
				$sql ="select * from index_post  where is_text=1 order by id desc ";
				$sql2="select id from index_post order by id desc limit 0,8";
			
				$pager = new Pagination($sql,6,4,$url,0,"post");
				$pager->setDebug(false);
				$data['blog'] = $pager->paginate($cache,$sql2);
		
				$cache->save('home_data',$data,300,'home');
		}
	
			
		
		$og='
<meta property="og:type" content="website" />
<meta property="og:image" content="http://mong.vn/public/images/logo2.png" />
<meta property="og:locale" content="vi_VN" /> 
<meta property="og:title" content="Đọc Truyện Online, Xem Video , Blog | Mong.vn - Kết nối trái tim" />
<meta property="og:description" content=" Đọc và chia sẻ các thể loại truyện chữ Online, xem video clip, blog miễn phí - Mộng.vn"/> 
<meta property="og:url" content="http://mong.vn"/> ';
   $data1['og']=$og;
   $data1['title']=HEAD;
   $data1['keyword']=KEYWORD;
   $data1['mota']=DES;
			
			
			
			loadview('template/header',$data1);
			if($_SESSION['mobile']!=0){
			loadview("truyen/list_home_mobi",$data);
			}else{
				loadview("truyen/list_home",$data);
			}
		
			
